package com.boot.main.controller;

import com.boot.main.entity.BcomCategory;
import com.boot.main.entity.BcomComment;
import com.boot.main.service.ICommentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/v1/api")
@Api(tags = "博客评论管理")
public class CommentController {
    @Resource
    private ICommentService commentService;

    @RequestMapping(value="/comments", method = RequestMethod.GET)
    @ApiOperation(value="获取评论列表")
    public Object getComments(@RequestParam("page") Integer page, @RequestParam("limit") Integer limit){
        return commentService.getComments(page, limit);
    }

    @RequestMapping(value="/blog/comment/list", method = RequestMethod.GET)
    @ApiOperation(value="获取评论列表")
    public Object getCommentsList(){
        return commentService.getCommentsList();
    }

    @RequestMapping(value="/blog/comment/{post_id}", method = RequestMethod.GET)
    @ApiOperation(value="获取评论列表")
    public Object getCommentsByPostId(@PathVariable("post_id") Long post_id){
        return commentService.getCommentsByPostId(post_id);
    }

    @RequestMapping(value="/comment", method = RequestMethod.POST)
    @ApiOperation(value="新增评论")
    public Object saveComment(@RequestBody BcomComment comment){
        return commentService.saveComment(comment);
    }

    @RequestMapping(value="/comment/{id}", method = RequestMethod.DELETE)
    @ApiOperation(value="删除评论")
    public Object deleteComment(@PathVariable Long id){
        return commentService.deleteComment(id);
    }
}
